package search

import "reflect"

func Linear(data []int, key int) int {
	if data == nil || len(data) == 0 {
		return -1
	}

	for i, n := 0, len(data); i < n; i++ {
		if data[i] == key {
			return i
		}
	}

	return -1
}

func LinearGeneric(data []interface{}, key interface{}) int {
	if data == nil || len(data) == 0 {
		return -1
	}
	for i, n := 0, len(data); i < n; i++ {
		if reflect.DeepEqual(data[i], key) {
			return i
		}
	}

	return -1
}
